import { createStore, combineReducers, applyMiddleware } from 'redux'
import logger from 'redux-logger'
import reducers from '@/reducers'
import createSagaMiddleware from 'redux-saga'
import rootSaga from '@/sagas'

const sagaMiddleware = createSagaMiddleware()

const cobRdrs = combineReducers({...reducers })

console.log('process.env.NODE_ENV', process.env.NODE_ENV)

const middlewares = [sagaMiddleware]

if(process.env.NODE_ENV === 'development'){
  middlewares.push(logger)
}

const store = createStore(cobRdrs, applyMiddleware(...middlewares))
 
sagaMiddleware.run(rootSaga)

export default store